From: Florian Müllner Date: Sun, 19 Mar 2017 13:42:35 +0000 (+0100) Subject: weather: Track whether a location was set X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~421 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d393ca4f09cc04d28eed92a2bc57fb01447a16b1;p=gnome-shell.git weather: Track whether a location was set Setting GWeatherInfo:location to null helpfully doesn't mean "no location", but "NYC". This obviously isn't what we want to show users, so track the location validity separately and consider it when updating the label shown to users. https://bugzilla.gnome.org/show_bug.cgi?id=780252 --- diff --git a/js/misc/weather.js b/js/misc/weather.js index 36346adbc..775d05301 100644 --- a/js/misc/weather.js +++ b/js/misc/weather.js @@ -17,6 +17,7 @@ const WeatherClient = new Lang.Class({ _init: function() { this._loading = false; + this._locationValid = false; this._lastUpdate = GLib.DateTime.new_from_unix_local(0); this._useAutoLocation = false; @@ -55,6 +56,10 @@ const WeatherClient = new Lang.Class({ return this._loading; }, + get hasLocation() { + return this._locationValid; + }, + get info() { return this._weatherInfo; }, @@ -64,6 +69,9 @@ const WeatherClient = new Lang.Class({ }, update: function() { + if (!this._locationValid) + return; + let now = GLib.DateTime.new_now_local(); // Update without loading indication if the current info is recent enough if (this._weatherInfo.is_valid() && @@ -101,6 +109,7 @@ const WeatherClient = new Lang.Class({ this._weatherInfo.abort(); this._weatherInfo.set_location(location); + this._locationValid = (location != null); if (location) this._loadInfo(); diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index eec19857d..18b5b0b4f 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -296,6 +296,9 @@ const WeatherSection = new Lang.Class({ }, _getLabelText: function() { + if (!this._weatherClient.hasLocation) + return _("Select a location…"); + if (this._weatherClient.loading) return _("Loading…");